package com.ingesup.services;

import java.util.List;

import com.ingesup.dao.ContactDao;
import com.ingesup.dao.ContactDaoImpl;
import com.ingesup.entities.Contact;
import org.springframework.flex.remoting.RemotingDestination;
import org.springframework.stereotype.Service;

/**
 * @author FDEJEAN
 */

@Service
@RemotingDestination("contactService")
public class ContactServiceImpl implements ContactService {

	private static ContactDao dao;
	
	static {
		dao = new ContactDaoImpl(Contact.class);
	}
	
	/**
	 * {@inheritDoc}
	 */
	@Override
	public Contact createContact(Contact toCreate) {
		return dao.create(toCreate);		
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public void updateContact(Contact toUpdate) {
		dao.update(toUpdate);		
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public void deleteContact(Contact toDelete) {
		dao.delete(toDelete);
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public Contact getContact(long id) {
		return dao.read(id);
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public List<Contact> getListContact() {
		return dao.getAll();
	}

}
